<?php
session_start(); //we need to call PHP's session object to access it through CI
class Materi extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->library('view');
		$this->view->set_menu('materi');
		$this->view->set_portlet_title('Materi');
		$this->view->set_portlet_style('portlet box green');
		$this->view->set_view('siswa/siswa_materi');
		$this->session_data = $this->session->userdata('user');
	}

	function index()
	{ 	
		$this->load();
		$this->load->model('m_materi');
		$this->data['rows'] = $this->m_materi->get_data_with_mp(array('sw_id'=>$this->data['id']));
		$this->data['title'] = 'Download Materi';
		$this->view->show($this->data);
	}
	
	function load(){
		if($this->session_data){
			$this->data['id'] = $this->session_data['id'];
			$this->data['username'] = $this->session_data['username'];
			$this->data['nama'] = $this->session_data['nama'];
		}else{
			redirect('user/login', 'refresh');
		}
	}
}
?>